package com.bases {
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;

	/**
	 * @author pethan
	 */
	public class SnapShoter {
		public static function snap(dp:DisplayObject):BitmapData {
			var bmd:BitmapData;
			var bounds:Rectangle = dp.getBounds(dp);
			bmd = new BitmapData(bounds.width, bounds.height, true, 0x00ff0000);
			bmd.draw(dp, new Matrix(1, 0, 0, 1, -bounds.x, -bounds.y));
			return bmd;
		}

		public static function snapBitmap(dp:DisplayObject):SCBitmap {
			var bitmap:SCBitmap = new SCBitmap(snap(dp));
			return bitmap;
		}

		/**
		 * 拍照, 但数据返回形式是SnapData.
		 * @return	SnapData
		 */
		public static function snap2(dp:DisplayObject):SnapData {
			var bmd:BitmapData;
			var bounds:Rectangle = dp.getBounds(dp);
			bmd = new BitmapData(bounds.width, bounds.height, true, 0x00ff0000);
			bmd.draw(dp, new Matrix(1, 0, 0, 1, -bounds.x, -bounds.y));
			return new SnapData(bounds.x, bounds.y, bmd);
		}
	}
}